package org.gpp.proj1.demo.map;

import java.io.IOException;

import org.gpp.proj1.map.GameMap;
import org.gpp.proj1.map.MalformedMapFileException;
import org.gpp.proj1.map.parser.MapFileParser;
import org.gpp.proj1.map.renderer.MapNodeBuilder;

import com.jme.app.SimpleGame;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;

public class MapDemo extends SimpleGame {
	
	public static void main(String[] args) {
		MapDemo demo = new MapDemo();
		demo.start();
	}

	@Override
	protected void simpleInitGame() {
		this.lightState.setGlobalAmbient( new ColorRGBA( 1.0f, 1.0f, 1.0f, 1.0f ) );
					
		GameMap map = null;
		try {
			map = MapFileParser.parseFile( "res/map/releaseMap.map" );
		} catch (IOException e) {
			e.printStackTrace();
		} catch (MalformedMapFileException e) {
			e.printStackTrace();
		}
		
		cam.setLocation( new Vector3f( 0, 300, 0 ) );
		cam.lookAt( new Vector3f( 200, 0, 200 ), new Vector3f( 0, 1, 0 ) );
		
		if( map != null ) {
			rootNode.attachChild( MapNodeBuilder.buildNode( map ) );
		}		
	}
}
